from digits import reverse
from numbers import isPalindrome

def isLychrel(n, iterations):
    for i in xrange(iterations):
        n += reverse(n)
        if isPalindrome(n): return False
        
    return True

def solution():
    print len([x for x in xrange(10000) if isLychrel(x, 50)])

from timeit import Timer
print Timer('solution()', 'from __main__ import solution').timeit(1)  

